﻿{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerheader.html"}
{literal}
<script type="text/javascript">
    $(function(){
        var Obmobile = $(".mobile");
        var Obcode = $("input[name=code]");

        //下一步注册
        $('.lcl_btn').click(function(){
            if(codeEmpty(Obcode) === false){
                return false;
            }else{
                document.myForm.submit();
            }
        });


        var count = 60;
        var myCountDown;
        $(function(){
            $(".reg-btn").click(function(){
                myCountDown = setInterval(countDown,1000);
                var mobile = Obmobile.text();
                var codetime = Obmobile.attr("v");
                $.ajax({
                    url:'/findpwd/sendcode',
                    data:{mobile:mobile,codetime:codetime},
                    type:'POST',
                    success:function(data){

                        if(data == "-6"){
                            $(".msg").html("不允许重复发送");
                            return;
                        }
                        if(data == "-5"){
                            $(".msg").html("手机号码不正确");
                            return;
                        }
                        return true;
                    },
                    dataType:'text'
                });
            });
        });

        function countDown(){
            $(".reg-btn").attr("disabled",true);
            $(".reg-btn").css("background","#999999");
            $(".reg-btn").val("重新获取验证码 （"+ count +"）");
            count--;
            if(count==0){
                $(".reg-btn").val("获取验证码").removeAttr("disabled");
                $(".reg-btn").css("background","#f4f4f4");
                clearInterval(myCountDown);
                count = 60;
            }
        }

        Obcode.blur(function(){
            codeEmpty(Obcode);
        });

    });


    function codeEmpty(obj){
        var code = obj.val();
        var mobile = $(".mobile").text();
        if(code==''){
            $('.msg').html("请输入验证码！");
            return false;
        }else{
            $.ajax({
                url:'/findpwd/confirmPhonecode',
                data:{code:code,mobile:mobile},
                async:false,
                type:'POST',
                success:function(data){

                    var data = eval("("+data+")");
                    var code = data.code;
                    var msg = data.msg;

                    if(code == 99){
                        $('.msg').html(msg);
                        result =  false;

                    }else{
                        $('.msg').html("");
                        result =  true;
                    }
                },
                dataType:'text'
            });
            return result;
        }
    }
</script>
<style>.technological_process li{width:200px;}</style>
{/literal}

<div class="clearfix"></div>

<div class="login_wrap">
	<div class="register_wrap">
        <ul class="technological_process">
            <li class="curr"><i>1</i>填写手机号码</li>
            <li class="curr"><i>2</i>验证手机号码</li>
            <li><i>3</i>修改密码</li>
            <li><i>4</i>修改成功</li>
        </ul>
        
        <ul class="tp_cp">
        <form method="post" target="_self" id="myForm" name="myForm"  action="/findpwd/changepwd">
        <span hidden class="mobile" v="{$codetime}">{$userinfo.moblie}</span>
            <input hidden  name="codetime" value="{$codetime}">
            <input hidden  name="moblie" class="moblie" value="{$userinfo.moblie}">
            <li><span class="fl mt8">　验证码：</span><input class="lcl_text wid18 fl"  name="code" type="text" placeholder="请输入验证码"/><div class="code-pic"><input class="reg-btn lcl_hq"  id="reg-btn" type="button" value="获取验证码"/><span class="msg pl10 orange" v="false"></span></div>
                </li>
            <li class="tp_cp_server"><input class="lcl_btn" type="button" value="下一步"/></li>
        </form>
        </ul>

    </div>
</div>


{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerfooter.html"}
